package com.tplan.tplanrabbitmqserver.sender;

import com.tplan.domain.Email;
import com.tplan.tplanrabbitmqserver.config.MQConfig;
import com.tplan.util.PojoUtil;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EmailMqSender {
    @Autowired
    AmqpTemplate amqpTemplate;

    public void sendEmail(Email message) {
        String msg = PojoUtil.beanToString(message);
        amqpTemplate.convertAndSend(MQConfig.TOPIC_EXCHANGE, MQConfig.EMAIL_ROUTING_KEY, msg);
    }
}
